﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using MxWeiXinPF.Common;
using MxWeiXinPF.Templates;

namespace MxWeiXinPF.Web.shop
{
    public partial class index : ShopBasePage
    {
        protected string _openid = "";
        public string bbsurl = "";
        public string carturl = "";
        public string indexurl = "";
        public string categoryurl = "";
        private BLL.wx_dt_user_BaseData daladd = new BLL.wx_dt_user_BaseData();
        public string indexContent = "";
        private int loginusershopid = 0;
        public string logourl = "";
        public string newproduct = "";
        public string searchurl = "";
        public string shoplist = "";
        public string shopName = "";
        public string shopurl = "";
        public string titleStr = "";
        public string toppicstr = "";
        public string totalproduct = "";
        public string userurl = "";
        public string cactegoryimg = "";
        private BLL.wxExecution wdal = new BLL.wxExecution();
        public string yuming = "";
        private Model.manager mshopmgr = null;

        #region MyRegion
        //private void getCategoryList()
        //{
        //    if (base.shopid == 0)
        //    {
        //        base.shopid = this.daladd.SelectShopIDByOpenid(this._openid);
        //    }
        //    int parentId = -1;
        //    int num2 = -1;
        //    int pageIndex = 1;
        //    int recordCount = 0;
        //    int pageSize = 0;
        //    if (pageSize <= 0)
        //    {
        //        pageSize = 2;
        //    }
        //    if (MyCommFun.RequestInt("page") > 0)
        //    {
        //        pageIndex = MyCommFun.RequestInt("page");
        //    }
        //    string filedOrder = " sort_id asc";
        //    StringBuilder builder = new StringBuilder();
        //    IList<Model.wx_shop_category> list = new BLL.wx_shop_category().GetCategoryListByWidShopid(this.wid, base.shopid, -1, parentId, num2);
        //    getCategoryImg(list);
        //    if ((list != null) && (list.Count > 0))
        //    {
        //        for (int i = 0; i < list.Count; i++)
        //        {
        //            string str2 = "";
        //            if ((list[i].link_url == null) || (list[i].link_url.Trim() == ""))
        //            {
        //                str2 = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/list.aspx?wid=", this.wid, "&shopid=", base.shopid, "&cid=", list[i].id }), this._openid);
        //            }
        //            else
        //            {
        //                str2 = MyCommFun.urlAddOpenid(list[i].link_url, this._openid);
        //            }
        //            if (list[i].isproductnum > 0)
        //            {
        //                builder.Append("<div class=\"item\"><a href=\"" + str2 + "\"><h1>" + list[i].title + "</h1><span class=\"more\">更多</span><div class=\"clear\"></div></a></div>");
        //                if ((list[i].catepicurl != null) && (list[i].catepicurl != ""))
        //                {
        //                    builder.Append("<div class=\"list\"><a href=\"" + str2 + "\"><img src=\"http://wx.9yyb.com" + list[i].catepicurl + "\"  class=\"ad_img ui_fluid\" style=\"width:100%;\" /></a></div>");
        //                }
        //                builder.Append("<div class=\"list\"><ul>");
        //                DataSet set = new DataSet();
        //                if (list[i].id != 0)
        //                {
        //                    set = new BLL.wx_shop_product().GetList(this.wid, list[i].id, pageSize, pageIndex, "upselling=1 and shopid=" + this.shopid, filedOrder, out recordCount);
        //                    if (((set != null) && (set.Tables.Count > 0)) && (set.Tables[0].Rows.Count > 0))
        //                    {
        //                        for (int j = 0; j < set.Tables[0].Rows.Count; j++)
        //                        {
        //                            DataRow row = set.Tables[0].Rows[j];
        //                            string str3 = "";
        //                           // string str4 = MyCommFun.getWebSite() + row["productpic"].ToString();
        //                            string str4 = "http://wx.9yyb.com" + row["productpic"].ToString();
        //                            if ((row["link_url"] != null) && (row["link_url"].ToString().Trim().Length > 0))
        //                            {
        //                                str3 = MyCommFun.urlAddOpenid(row["link_url"].ToString().Trim(), this._openid);
        //                            }
        //                            else
        //                            {
        //                                str3 = MyCommFun.urlAddOpenid(string.Concat(new object[] { "detail.aspx?wid=", this.wid, "&pid=", row["id"].ToString()}), this._openid);
        //                            }
        //                            if ((j % 2) == 0)
        //                            {
        //                                builder.Append("<li class=\"list_li_right\"><a href=\"" + str3 + "\"><img src=\"" + str4 + "\" width=\"140\" height=\"140\" class=\"default\">");
        //                                if ((row["isrx"].ToString().Equals("1") || row["isrx"].ToString().Equals("true")) || row["isrx"].ToString().Equals("True"))
        //                                {
        //                                    builder.Append("<div class=\"title\"><img src=\"/upload/rx.png\"/> " + row["productName"].ToString() + " </div>");
        //                                }
        //                                else
        //                                {
        //                                    builder.Append("<div class=\"title\">" + row["productName"].ToString() + " </div>");
        //                                }
        //                                builder.Append("<div class=\"price\"><span class=\"now_price\">￥" + row["salePrice"].ToString() + "</span><span class=\"old_price\">￥" + row["MarketPrice"].ToString() + "</span>");
        //                                builder.Append("</div></a></li>");
        //                            }
        //                            else
        //                            {
        //                                builder.Append("<li class=\"list_li_left\"><a href=\"" + str3 + "\"><img src=\"" + str4 + "\" width=\"140\" height=\"140\" class=\"default\">");
        //                                if ((row["isrx"].ToString().Equals("1") || row["isrx"].ToString().Equals("true")) || row["isrx"].ToString().Equals("True"))
        //                                {
        //                                    builder.Append(" <div class=\"title\"><img src=\"/upload/rx.png\"/> " + row["productName"].ToString() + "</div>");
        //                                }
        //                                else
        //                                {
        //                                    builder.Append("<div class=\"title\"> " + row["productName"].ToString() + " </div>");
        //                                }
        //                                builder.Append("<div class=\"price\"><span class=\"now_price\">￥" + row["salePrice"].ToString() + "</span><span class=\"old_price\">￥" + row["MarketPrice"].ToString() + "</span>");
        //                                builder.Append("</div></a></li>");
        //                            }
        //                        }
        //                    }
        //                }
        //                builder.Append("<div class=\"clear\"></div></ul></div>");
        //            }
        //        }
        //    }
        //    this.indexContent = builder.ToString();
        //} 
        #endregion

        #region MyRegion
        //private void getCategoryList3()
        //{
        //    if (base.shopid == 0)
        //    {
        //        base.shopid = this.daladd.SelectShopIDByOpenid(this._openid);
        //    }
        //    int parentId = -1;
        //    int num2 = -1;
        //    int pageIndex = 1;
        //    int recordCount = 0;
        //    int pageSize = 0;
        //    if (pageSize <= 0)
        //    {
        //        pageSize = 3;
        //    }
        //    if (MyCommFun.RequestInt("page") > 0)
        //    {
        //        pageIndex = MyCommFun.RequestInt("page");
        //    }
        //    string filedOrder = " sort_id asc";
        //    StringBuilder builder = new StringBuilder();
        //    IList<Model.wx_shop_category> list = new BLL.wx_shop_category().GetCategoryListByWidShopid(this.wid, base.shopid, -1, parentId, num2);
        //    if ((list != null) && (list.Count > 0))
        //    {
        //        for (int i = 0; i < list.Count; i++)
        //        {
        //            string str2 = "";
        //            if ((list[i].link_url == null) || (list[i].link_url.Trim() == ""))
        //            {
        //                str2 = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/list.aspx?wid=", this.wid, "&shopid=", base.shopid, "&cid=", list[i].id }), this._openid);
        //            }
        //            else
        //            {
        //                str2 = MyCommFun.urlAddOpenid(list[i].link_url, this._openid);
        //            }
        //            if (list[i].isproductnum > 0)
        //            {
        //                builder.Append("<div class=\"item\"><a href=\"" + str2 + "\"><h1>" + list[i].title + "</h1><span class=\"more\">更多</span><div class=\"clear\"></div></a></div>");
        //                builder.Append("<div class=\"list\"><ul>");
        //                DataSet set = new DataSet();
        //                if (list[i].id != 0)
        //                {
        //                    set = new BLL.wx_shop_product().GetList(this.wid, list[i].id, pageSize, pageIndex, "upselling=1 and shopid=" + base.shopid, filedOrder, out recordCount);
        //                    if (((set != null) && (set.Tables.Count > 0)) && (set.Tables[0].Rows.Count > 0))
        //                    {
        //                        builder.Append("<div class=\"discount\">");
        //                        for (int j = 0; j < set.Tables[0].Rows.Count; j++)
        //                        {
        //                            DataRow row = set.Tables[0].Rows[j];
        //                            string str3 = "";
        //                            string str4 = MyCommFun.getWebSite() + row["productpic"].ToString();
        //                            if ((row["link_url"] != null) && (row["link_url"].ToString().Trim().Length > 0))
        //                            {
        //                                str3 = MyCommFun.urlAddOpenid(row["link_url"].ToString().Trim(), this._openid);
        //                            }
        //                            else
        //                            {
        //                                str3 = MyCommFun.urlAddOpenid(string.Concat(new object[] { "detail.aspx?wid=", this.wid, "&pid=", row["id"].ToString() }), this._openid);
        //                            }
        //                            if ((i % 2) == 0)
        //                            {
        //                                if (j == 0)
        //                                {
        //                                    builder.Append("<div class=\"left_floor\">");
        //                                    builder.Append("<a href=\"" + str3 + "\"><img src=\"" + str4 + "\"></a>");
        //                                    builder.Append("</div>");
        //                                    builder.Append("<div class=\"right_floor\">");
        //                                }
        //                                else if (j == 1)
        //                                {
        //                                    builder.Append("<a href=\"" + str3 + "\" class=\"up\"><img src=\"" + str4 + "\"></a>");
        //                                }
        //                                else
        //                                {
        //                                    builder.Append("<a href=\"" + str3 + "\" class=\"down\"><img src=\"" + str4 + "\"></a>");
        //                                }
        //                            }
        //                            else if (j == 0)
        //                            {
        //                                builder.Append("<div class=\"left_floor\">");
        //                                builder.Append("<a href=\"" + str3 + "\" class=\"up\"><img src=\"" + str4 + "\"></a>");
        //                            }
        //                            else if (j == 1)
        //                            {
        //                                builder.Append("<a href=\"" + str3 + "\" class=\"down\"><img src=\"" + str4 + "\"></a>");
        //                            }
        //                            else
        //                            {
        //                                builder.Append("</div>");
        //                                builder.Append("<div class=\"right_floor\">");
        //                                builder.Append("<a href=\"" + str3 + "\"><img src=\"" + str4 + "\"></a>");
        //                            }
        //                        }
        //                        builder.Append("</div>");
        //                        builder.Append("<div class=\"clear\"></div>");
        //                        builder.Append("</div>");
        //                    }
        //                }
        //                builder.Append("<div class=\"clear\"></div></ul></div>");
        //            }
        //        }
        //    }
        //    this.indexContent = builder.ToString();
        //} 
        #endregion

        private void getCategoryList2()
        {
            int parentId = -1;
            int class_layer = -1;
            int pageIndex = 1;
            int recordCount = 0;
            int pageSize = 4;
            if (MyCommFun.RequestInt("page") > 0)
            {
                pageIndex = MyCommFun.RequestInt("page");
            }
            string filedOrder = " sort_id asc";
            StringBuilder builder = new StringBuilder();
            IList<Model.wx_shop_category> list = new BLL.wx_shop_category().GetCategoryListByWid(this.wid, -1, parentId, class_layer);
            DataSet cateds = new BLL.indexcatepic().GetList(100," shopid = " + base.shopid + " " , "");
           
            DataSet set = new DataSet();
            set = new BLL.wx_shop_product().GetList(this.wid, 20000, pageIndex, "upselling=1 and shopid=" + this.shopid, filedOrder, out recordCount);
            getCategoryImg(list,set);
            if ((list != null) && (list.Count > 0))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    string str2 = "";
                    if ((list[i].link_url == null) || (list[i].link_url.Trim() == ""))
                    {
                        str2 = MyCommFun.urlAddOpenid(string.Concat(new object[] {  MyCommFun.getWebSite(),"/shop/list.aspx?wid=", this.wid, "&shopid=", base.shopid, "&cid=", list[i].id }), this._openid);
                    }
                    else
                    {
                        str2 = MyCommFun.urlAddOpenid(list[i].link_url, this._openid);
                    }
                    StringBuilder sb = new StringBuilder();
                    DataRow[] tempdrs = set.Tables[0].Select(" categoryId=" + list[i].id);

                    if (list[i].isproductnum > 0 && (tempdrs != null && tempdrs.Length > 0))
                    {
                        sb.Append("<div class=\"cpbj\">");
                        sb.Append("<div class=\"goodstit goodstit2 clearfix\"><div class=\"bk\"></div><a href=\"" + str2 + "\">更多</a><b>" + list[i].title + "</b></div>");
                        if (cateds != null && cateds.Tables.Count > 0 && cateds.Tables[0].Rows.Count > 0)
                        {
                            DataRow[] catedrs = cateds.Tables[0].Select(" categoryid=" + list[i].id);
                            if (catedrs != null && catedrs.Length > 0)
                            {
                                if (!string.IsNullOrEmpty(catedrs[0]["img_url"].ToString()))
                                {
                                    sb.Append("<div class=\"titt\"><a href=\"" + catedrs[0]["link_url"].ToString() + "\" class=\"jumpurl\" data-url=\"" + catedrs[0]["img_url"].ToString() + "\"><img class=\"lazy img-error1\" src=\"" + catedrs[0]["img_url"].ToString() + "\" data-original=\"" + catedrs[0]["img_url"].ToString() + "\"></a></div>");
                                }
                            }
                        }
                        sb.Append("<div class=\"colums colums2\">");
                        sb.Append(" <ul class=\"clearfix\">");
                        for (int j = 0; j < tempdrs.Length && j < 3; j++)
                        {
                            DataRow row = tempdrs[j];
                            string str4 = MyCommFun.getWebSite() + row["productpic"].ToString();
                            //  string str4 = "http://wx.9yyb.com" + row["productpic"].ToString();
                            string str3 = "";
                            if ((row["link_url"] != null) && (row["link_url"].ToString().Trim().Length > 0))
                            {
                                str3 = MyCommFun.urlAddOpenid(row["link_url"].ToString().Trim(), this._openid);
                            }
                            else
                            {
                                str3 = MyCommFun.urlAddOpenid(string.Concat(new object[] { "detail.aspx?wid=", this.wid, "&pid=", row["id"].ToString(), "&shopid=", this.shopid }), this._openid);
                            }
                            sb.Append("<li class=\"productdetail\" onClick=\"javascript:window.location.href='" + str3 + "'\">");
                            sb.Append("<img class=\"lazy img-error1\" src=\"" + str4 + "\" data-original=\"" + str4 + "\"></a>");
                            sb.Append("<span class=\"sem_name\" data-length=\"32\">" + row["productName"].ToString() + "</span>");
                            sb.Append("<span style=\"color:#f5280d;font-size:1.0em\">折扣价:￥" + row["salePrice"].ToString() + "</span><span class=\"color:#666; text-decoration:line-through;font-size:1.2em\">市场价:￥" + row["MarketPrice"].ToString() + "</span></li>");
                        }
                        sb.Append("</ul></div>"); //<div colums colums2>

                        sb.Append("</div>"); //cpog
                        sb.Append("<div class=\"fg\"></div>");
                        builder.Append(sb.ToString());
                    }
                }
            }
            this.indexContent = builder.ToString();
        }
        private void getIndexList()
        {
            if (base.shopid == 0)
            {
                base.shopid = this.daladd.SelectShopIDByOpenid(this._openid);
            }
            int parentId = -1;
            int num2 = -1;
            int num3 = 1;
            int num5 = 0;
            if (num5 <= 0)
            {
                num5 = 2;
            }
            if (MyCommFun.RequestInt("page") > 0)
            {
                num3 = MyCommFun.RequestInt("page");
            }
            StringBuilder builder = new StringBuilder();
            IList<Model.wx_shop_category> list = new BLL.wx_shop_category().GetCategoryListByWidShopid(this.wid, base.shopid, -1, parentId, num2);
            if ((list != null) && (list.Count > 0))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    string str2 = "";
                    if ((list[i].link_url == null) || (list[i].link_url.Trim() == ""))
                    {
                        str2 = MyCommFun.getWebSite() + MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/list.aspx?wid=", this.wid, "&shopid=", base.shopid, "&cid=", list[i].id }), this._openid);
                    }
                    else
                    {
                        str2 = MyCommFun.getWebSite() + MyCommFun.urlAddOpenid(list[i].link_url, this._openid);
                    }
                    if (list[i].isproductnum > 0)
                    {
                        builder.Append("<div class=\"item\"><a href=\"" + str2 + "\"><h1>" + list[i].title + "</h1><span class=\"more\">更多</span><div class=\"clear\"></div></a></div>");
                        builder.Append("<div class=\"list\"><ul>");
                        if ((i % 2) == 1)
                        {
                            builder.Append("<div class=\"discount\">");
                            builder.Append("<div class=\"left_floor\">");
                            builder.Append("<a href=\"#\"><img src=\"images/1.jpg\"></a>");
                            builder.Append("</div>");
                            builder.Append("<div class=\"right_floor\">");
                            builder.Append("<a href=\"#\" class=\"up\"><img src=\"images/2.jpg\"></a><a href=\"#\" class=\"down\"><img src=\"images/3.jpg\"></a>");
                            builder.Append("</div>");
                            builder.Append("<div class=\"clear\"></div>");
                            builder.Append("</div>");
                        }
                        else
                        {
                            builder.Append("<div class=\"discount\">");
                            builder.Append("<div class=\"left_floor\">");
                            builder.Append("<a href=\"#\" class=\"up\"><img src=\"images/2.jpg\"></a><a href=\"#\" class=\"down\"><img src=\"images/3.jpg\"></a>");
                            builder.Append("</div>");
                            builder.Append("<div class=\"right_floor\">");
                            builder.Append("<a href=\"#\"><img src=\"images/1.jpg\"></a>");
                            builder.Append("</div>");
                            builder.Append("<div class=\"clear\"></div>");
                            builder.Append("</div>");
                        }
                        builder.Append("<div class=\"clear\"></div></ul></div>");
                    }
                }
            }
            this.indexContent = builder.ToString();
        }

        private void getProductNumber()
        {
            DataSet set = new BLL.wx_shop_product().getProductNumberbyShopID(this.wid, this.shopid);
            if ((set != null) && (set.Tables[0].Rows.Count > 0))
            {
                if ((set.Tables[0].Rows[0]["totalproduct"].ToString() != null) && (set.Tables[0].Rows[0]["totalproduct"].ToString() != ""))
                {
                    this.totalproduct = set.Tables[0].Rows[0]["totalproduct"].ToString();
                }
                if ((set.Tables[0].Rows[0]["newproduct"].ToString() != null) && (set.Tables[0].Rows[0]["newproduct"].ToString() != ""))
                {
                    this.newproduct = set.Tables[0].Rows[0]["newproduct"].ToString();
                }
            }
        }

        //private void getShopList()
        //{
        //    StringBuilder builder = new StringBuilder();
        //    string strWhere = " 1=1";
        //    if (base.shopid != 0x27)
        //    {
        //        strWhere = strWhere + " and id= 39";
        //    }
        //    else
        //    {
        //        object obj2 = strWhere;
        //        strWhere = string.Concat(new object[] { obj2, " and id=", base.shopid, " " });
        //    }
        //    DataSet dateSetFromDtManager = this.daladd.GetDateSetFromDtManager(strWhere);
        //    if ((dateSetFromDtManager != null) && (dateSetFromDtManager.Tables.Count > 0))
        //    {
        //        int num = 0;
        //        int num2 = 0;
        //        foreach (DataTable table in dateSetFromDtManager.Tables)
        //        {
        //            foreach (DataRow row in table.Rows)
        //            {
        //                if (num == 0)
        //                {
        //                    builder.Append(string.Concat(new object[] { "<div style=\"border-top:1px solid #646464;position:relative;margin-top:-1px;background-color:#141414;height: auto;min-height: 38px;font-size: 1.1em;color: #fff;padding: 10px 10px 0 10px;line-height:38px;\" id=\"initial_", num2, "\" onclick=\"show_hide_initial(", num2, ")\"><strong style=\"display: block;width: 30px;height: 26px;line-height: 26px;overflow: hidden;float: left;\">", table.Rows[num][1].ToString().Trim(), " </strong><span style=\"font-size:12px; height:26px; line-height:26px; display:inline-block;\">▼</span></div>" }));
        //                    builder.Append("<ul id=\"initial_list_" + num2 + "\" style=\"display: none;\">");
        //                    builder.Append(string.Concat(new object[] { "<li><a href='index.aspx?wid=", this.wid, "&shopid=", table.Rows[num][2].ToString().Trim(), "&openid=", this._openid, "'>", table.Rows[num][0].ToString().Trim(), " </a></li>" }));
        //                }
        //                else
        //                {
        //                    if (table.Rows[num][1].ToString().Trim() == table.Rows[num - 1][1].ToString().Trim())
        //                    {
        //                        builder.Append(string.Concat(new object[] { "<li><a href='index.aspx?wid=", this.wid, "&shopid=", table.Rows[num][2].ToString().Trim(), "&openid=", this._openid, "'>", table.Rows[num][0].ToString().Trim(), " </a></li>" }));
        //                    }
        //                    else
        //                    {
        //                        num2++;
        //                        builder.Append("</ul>");
        //                        builder.Append(string.Concat(new object[] { "<div style=\"border-top:1px solid #646464;position:relative;margin-top:-1px;background-color:#141414;height: auto;min-height: 38px;font-size: 1.1em;color: #fff;padding: 10px 10px 0 10px;line-height:38px;\" id=\"initial_", num2, "\" onclick=\"show_hide_initial(", num2, ")\"><strong style=\"display: block;width: 30px;height: 26px;line-height: 26px;overflow: hidden;float: left;\">", table.Rows[num][1].ToString().Trim(), " </strong><span style=\"font-size:12px; height:26px; line-height:26px; display:inline-block;\">▼</span></div>" }));
        //                        builder.Append("<ul id=\"initial_list_" + num2 + "\" style=\"display: none;\">");
        //                        builder.Append(string.Concat(new object[] { "<li><a href='index.aspx?wid=", this.wid, "&shopid=", table.Rows[num][2].ToString().Trim(), "&openid=", this._openid, "'>", table.Rows[num][0].ToString().Trim(), " </a></li>" }));
        //                    }
        //                    if (num == table.Rows.Count)
        //                    {
        //                        builder.Append("</ul>");
        //                    }
        //                }
        //                num++;
        //            }
        //        }
        //    }
        //    this.shoplist = builder.ToString();
        //}

        private void getShopTopPic()
        {
            StringBuilder builder = new StringBuilder();
            DataSet listTopPic = new BLL.indextoppic().GetListTopPic(this.shopid);
            if ((listTopPic != null) && (listTopPic.Tables[0].Rows.Count > 0))
            {
                for (int i = 0; i < listTopPic.Tables[0].Rows.Count; i++)
                {
                    int num2 = i + 1;
                    builder.Append(string.Concat(new object[] { "<li style='display: table-cell; vertical-align: top; width: 640px;'><span class=\"img_", num2, "\"> <a href='javascript:;' class='jumpurl'><img src=\"", listTopPic.Tables[0].Rows[i]["img_url"].ToString(), "\"></a></li>" }));
                }
            }
            else
            {
                builder.Append("<li ><span class=\"img_3\"><img src=\"/shop/templates/default/images/img_main_1.png\"></span></li>");
                builder.Append("<li><span class=\"img_4\"><img src=\"/shop/templates/default/images/img_main_2.png\"></span></li>");
                builder.Append("<li><span class=\"img_1\"><img src=\"/shop/templates/default/images/img_main_3.png\"></span></li>");
                builder.Append("<li><span class=\"img_2\"><img src=\"/shop/templates/default/images/img_main_4.png\"></span></li>");
                builder.Append("<li><span class=\"img_5\"><img src=\"/shop/templates/default/images/img_main_5.png\"></span></li>");
            }
            this.toppicstr = builder.ToString();
        }

        private void getCategoryImg(IList<Model.wx_shop_category> list,DataSet set)
        {
            if ((list != null) && (list.Count > 0))
            {
                StringBuilder builder = new StringBuilder();
                int index = 1;
                for (int i = 0; i < list.Count; i++) //前8个
                {
                    if (index >= 9)
                    {
                        break;
                    }
                    DataRow[] tempdrs = set.Tables[0].Select(" categoryId=" + list[i].id);
                    if (list[i].isproductnum > 0 && (tempdrs != null && tempdrs.Length > 0))
                    {
                        builder.Append(
                            string.Concat(new object[] { 
                            "<li><a href=\"/shop/list.aspx?wid=",this.wid,"&cid=",list[i].id,"&openid=",this._openid,"&shopid=",this.shopid," \"><i class=\"i",index,"\"><img src=\"", 
                            list[i].index_ico_url, "\"></i><span>",list[i].title,"</span></a></a>" }));
                        index++;
                    }

                }
                this.cactegoryimg = builder.ToString();
            }

        }
        protected override void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this._openid = MyCommFun.RequestOpenid();
                string url = "";
                this.wid = MyCommFun.RequestInt("wid");
                base.userModel = base.GetUserInfo();
                if ((base.userModel != null) && (MyCommFun.RequestOpenid() != base.userModel.wxOpenId))
                {
                    this._openid = base.userModel.wxOpenId;
                }
                this.shopid = this.daladd.SelectShopIDByOpenid(this._openid);
                if (this.shopid != 0)
                {
                    mshopmgr = new BLL.manager().GetModel(this.shopid);
                }
                else
                {
                    this.shopid = this.daladd.SelectShopIDByOpenid(this._openid);
                    mshopmgr = new BLL.manager().GetModel(this.shopid);
                }
                if (mshopmgr != null)
                {
                    this.shopName = mshopmgr.real_name;
                }
                if (CheckHasStaticPage(this.shopid))
                {
                    url = string.Concat(new object[] { MyCommFun.getWebSite(), "/shop/index_", this.shopid, ".aspx?wid=", this.wid, "&openid=", _openid, "&shopid=", this.shopid });
                    base.Response.Redirect(url);
                }
                


                this.shopurl = string.Concat(new object[] { "index.aspx?wid=", this.wid, "&shopid=", this.shopid, "&openid=", this._openid });
                #region MyRegion
                //if (this.loginusershopid == this.shopid)
                //{
                //    this.shopurl = string.Concat(new object[] { "index.aspx?wid=", this.wid, "&shopid=39&openid=", this._openid });
                //}
                //else if (this.loginusershopid != 0)
                //{
                //    this.shopurl = string.Concat(new object[] { "index.aspx?wid=", this.wid, "&shopid=", this.loginusershopid, "&openid=", this._openid });
                //}
                //else
                //{
                //    this.shopurl = string.Concat(new object[] { "index.aspx?wid=", this.wid, "&shopid=39&openid=", this._openid });
                //} 
                #endregion
                this.yuming = MyCommFun.getWebSite();
                this.categoryurl = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/category.aspx?wid=", this.wid, "&shopid=", this.shopid }), this._openid);
                this.carturl = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/cart.aspx?wid=", this.wid, "&shopid=", this.shopid }), this._openid);
                this.userurl = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/userinfo.aspx?wid=", this.wid, "&shopid=", this.shopid }), this._openid);
                this.searchurl = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/search.aspx?wid=", this.wid, "&shopid=", this.shopid }), this._openid);
                this.bbsurl = MyCommFun.urlAddOpenid(string.Concat(new object[] { "/shop/userbbsadd.aspx?wid=", this.wid, "&shopid=", this.shopid }), this._openid);
                if (!this.Page.IsPostBack)
                {
                    this.getShopTopPic();
                    // this.getProductNumber();
                    this.getCategoryList2();

                }

            }
            catch (Exception ex)
            {

            }
        }

        private bool CheckHasStaticPage(int shopid)
        {
            string path = Server.MapPath("~/shop/");
            string filepath = path + "index_" + shopid.ToString() + ".aspx";
            if (System.IO.File.Exists(filepath))
            {
                return true;
            }
            return false;
        }
    }
}